package cn.xhy.material.dal.mysql.depot;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.xhy.material.controller.admin.depot.vo.DepotPageReqVO;
import cn.xhy.material.dal.dataobject.depot.DepotDO;
import org.apache.ibatis.annotations.Mapper;


/**
 * 仓库 Mapper
 *
 * @author xhy
 */
@Mapper
public interface DepotMapper extends BaseMapperX<DepotDO> {

    default PageResult<DepotDO> selectPage(DepotPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DepotDO>()
                .likeIfPresent(DepotDO::getName, reqVO.getName())
                .eqIfPresent(DepotDO::getAddress, reqVO.getAddress())
                .eqIfPresent(DepotDO::getWarehousing, reqVO.getWarehousing())
                .eqIfPresent(DepotDO::getTruckage, reqVO.getTruckage())
                .eqIfPresent(DepotDO::getType, reqVO.getType())
                .eqIfPresent(DepotDO::getSort, reqVO.getSort())
                .eqIfPresent(DepotDO::getRemark, reqVO.getRemark())
                .eqIfPresent(DepotDO::getPrincipal, reqVO.getPrincipal())
                .eqIfPresent(DepotDO::getEnabled, reqVO.getEnabled())
                .eqIfPresent(DepotDO::getIsDefault, reqVO.getIsDefault())
                .betweenIfPresent(DepotDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DepotDO::getId));
    }

}
